#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
#include<stdlib.h>
//测试僵尸进程
/*int main()
{
  pid_t id = fork();
  if(id == 0)
  {
    int count = 5;
    while(count--)
    {
      printf("i am child process,pid = %d,ppid = %d\n",getpid(),getppid());
      sleep(1);
    }
  }
  else 
  {
    while(1)
    {
      printf("i am parent process,pid = %d,ppid = %d\n",getpid(),getppid());
      sleep(1);   
    }
  }
}*/
//测试孤儿进程
int main()
{
  pid_t id = fork();
  if(id == 0)
  {
    int count = 50;
    while(count--)
    {
      printf("i am child process,pid = %d,ppid = %d\n",getpid(),getppid());
      sleep(1);
    }
  }
  else 
  {
    int test = 5;
    while(test --)
    {
      printf("i am parent process,pid = %d,ppid = %d\n",getpid(),getppid());
      sleep(1);   
    }
  }
    return 0;
}
